#!/bin/sh

#set -e -x

# Create needed directories
# Ignore errors
mkdir -p $SNAP_COMMON/etc || :
mkdir -p $SNAP_COMMON/var/log || :
mkdir -p $SNAP_COMMON/var/lock || :
mkdir -p $SNAP_COMMON/var/dev || :
mkdir -p $SNAP_COMMON/quirks || :

# Put config files in place
#
# Do not overwrite files and ignore errors, to not reset user configuration
# when running as root and to not have ugly error messages when running as
# non-root.
yes no | cp -i $SNAP/usr/share/ipp-usb/quirks/* $SNAP_COMMON/quirks >/dev/null 2>&1 || :
if [ ! -f $SNAP_COMMON/etc/ipp-usb.conf ]; then
    cp $SNAP/etc/ipp-usb.conf $SNAP_COMMON/etc/ >/dev/null 2>&1 || :
fi

# Run ipp-usb with the command line arguments with which we were called
exec $SNAP/sbin/ipp-usb "$@"
